package sjtu.sonnet.LDAPModule.logic.controller;

import java.util.ArrayList;
import java.util.Enumeration;

import javax.naming.directory.Attributes;

import sjtu.sonnet.LDAPModule.logic.interfraces.iLDAPController;
import sjtu.sonnet.LDAPModule.service.interfaces.LDAPManager;

public class LDAPController implements iLDAPController {
	private LDAPManager ldapManager = null;

	public LDAPController() {
		System.out.println("LDAPController Initialized!");
	}

	public void setLdapManager(LDAPManager ldapManager) {
		System.out.println("LDAPManager set!");
		this.ldapManager = ldapManager;
	}

	public LDAPManager getLdapManager() {
		return ldapManager;
	}

	public Boolean addUser(String userName, String groupName,
			ArrayList rolesList, String note) {
		return this.ldapManager.addUser(userName, groupName, rolesList, note);
	}

	public Boolean addUserGroup(String newGroupName, String parentGroupName) {
		return this.ldapManager.addUserGroup(newGroupName, parentGroupName);
	}

	public void delete_DN(String DN) {
		this.ldapManager.delete_DN(DN);
	}

	public void delete_OU(String name) {
		this.ldapManager.delete_OU(name);
	}

	public void delete_UID(String name) {
		this.ldapManager.delete_UID(name);
	}

	public Attributes findUid(String uid, String baseDN) throws Exception {
		return this.ldapManager.findUid(uid, baseDN);
	}

	public Attributes findUid(String DN) {
		return this.ldapManager.findUid(DN);
	}

	public Boolean reName(String oldDN, String newDN) {
		return this.ldapManager.reName(oldDN, newDN);
	}

	public Enumeration search_OneLevel(String title) {
		return this.ldapManager.search_OneLevel(title);
	}

	public Enumeration search_SubTree(String title) {
		return this.ldapManager.search_SubTree(title);
	}

}
